package client;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class SSHClient {
	public static void main(String[] args) throws UnknownHostException, IOException {
//		Socket socket = new Socket("127.0.0.1",8888);
		Socket socket = new Socket("127.0.0.1",7777);
		OutputStream out = socket.getOutputStream();
		InputStream in = socket.getInputStream();
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		Scanner scanner = new Scanner(System.in);
		
		File f = new File("D:\\Client");
		if(!f.exists()){
			f.mkdirs();
		}
		
		while(true){
			
			String command = scanner.nextLine();
			String[] ss = command.split("\\s+");
			if(ss.length==3){
				File file = new File("D:\\Client\\"+ss[1]);
				if(!file.exists()){
					command = "error";              ///如果scp发送的文件不存在，就把命令改为error发送。
				}
			}
			out.write(command.getBytes());
		}
		
	}
}
